﻿@model IEnumerable<MAPDavy.WebMVC3.Models.UserDTO>

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section JavaScript{
    <script type="text/javascript">
        $(document).ready(function () {

            $("#users tbody tr").hover(
                function () {
                    $(this).addClass("ui-state-highlight");
                },
                function () {
                    $(this).removeClass("ui-state-highlight");
            });

            $("#users tbody tr th").addClass("ui-widget ui-widget-header");


            $(".deleteLink").click(function (e) {
                e.preventDefault();

                var tr = $(this).parents("tr");
                var _id = tr.find("input:hidden").val();

                jConfirm('Desea Eliminar el Item Seleccionado', 'Confirmación', function (r) {
                    if (r) {
                        $.post(
                            '@Url.Action("Delete", "Account")',
                             { id: _id },
                             function (ok) {
                                if (ok) {
                                    $(tr).fadeOut("slow", function () {
                                        $(tr).remove();
                                    });
                                }
                                else {
                                    jAlert("No se ha puede Eliminar el Item Seleccionado", "Advertencia");
                               }
                             },
                             "json"
                        );
                    }
                });
            });
        });
    </script>
}
<div class="cpanel ui-widget ui-widget-content ui-corner-all">
    <table class="toolbar">
        <tr>
            <td valign="middle" >
                <img src="@Url.Content("~/Content/images/user2.png")" title="Usuarios" alt="Usuarios" />
            </td>
            <td class="tdHeader"><span class="header">Usuarios</span></td>
            <td><center>
                <a href="@Url.Action("Register", "Account")">
                    <img src="@Url.Content("~/Content/images/newUser2.png")" title="Crear Usuario" alt="Crear Usuario" />
                    <br /><span class="label">Nuevo</span>
                </a></center>
            </td>
        </tr>
    </table>
</div>
<table id="users">
    <tr>
        <th>
            User Name
        </th>
        <th>
            Email
        </th>
        <th>
            Is Online
        </th>
        <th>
            Is Locked Out
        </th>
        <th>
            Last Login Date
        </th>
        <th>
            Acctions
        </th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.Hidden("userName", item.UserName)
            @Html.DisplayFor(modelItem => item.UserName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Email)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.IsOnline)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.IsLockedOut)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.LastLoginDate)
        </td>
        <td>
            <a href="@Url.Action("CambiarPassword", "Account", new { id = item.UserName })" >
                    <img src="@Url.Content("~/Content/images/changePws.png")" title="CambiarPassword" alt="CambiarPassword" /></a>
            <a href="@Url.Action("AgignarRol", "Account", new { id = item.UserName })" >
                    <img src="@Url.Content("~/Content/images/asignarRol.png")" title="Configurar Roles" alt="Configurar Roles" /></a>
            <a href="@Url.Action("Delete", "Account", new { id = item.UserName })" class = "deleteLink cerrado">
                    <img src="@Url.Content("~/Content/images/delete.png")" title="Eliminar Evaluación" alt="Eliminar Evaluación" /></a>
        </td>
    </tr>
}

</table>
